<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="/backstages/style/css/ch-ui.admin.css">
    <link rel="stylesheet" href="/backstages/style/font/css/font-awesome.min.css">
    <script type="text/javascript" src="/backstages/style/js/jquery-1.8.3.min.js" ></script>
</head>
<body>
    <!--面包屑导航 开始-->
    <!--<div class="crumb_warp">
        <i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商品管理</a> &raquo; 添加商品
    </div>-->
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
	<div class="result_wrap">
        <!-- <div class="result_title">
            <h3>快捷操作</h3>
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href="#"><i class="fa fa-plus"></i>新增文章</a>
                <a href="#"><i class="fa fa-recycle"></i>批量删除</a>
                <a href="#"><i class="fa fa-refresh"></i>更新排序</a>
            </div>
        </div> -->
    </div>
    <!--结果集标题与导航组件 结束-->
    
    <div class="result_wrap">
        <form action="#" method="post">
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th width="120">父级菜单：</th>
                        <td>

                                <select name="" id="one" >

                                    <option>==请选择==</option>

                                </select>



                                <select name="" id="tow" >

                                    <option>==请选择==</option>

                                </select>



                                <select name="" id="three" >

                                    <option>==请选择==</option>

                                </select>


                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>菜单名称：</th>
                        <td>
                            <input type="text" name="menu_name">
                            <!-- <span><i class="fa fa-exclamation-circle yellow"></i>这里是默认长度</span> -->
                        </td>
                    </tr>
                    <tr>
                        <th>菜单图标：</th>
                        <td>
                            <input type="text" name="icon">
                            <!-- <span><i class="fa fa-exclamation-circle yellow"></i>这里是默认长度</span> -->
                        </td>
                    </tr>
                    <tr>
                        <th>菜单路由：</th>
                        <td>
                            <input type="text" name="action">
                            <!-- <span><i class="fa fa-exclamation-circle yellow"></i>这里是默认长度</span> -->
                        </td>
                    </tr>
                    <tr>
                        <th>菜单路径：</th>
                        <td>
                            <input type="text" name="url">
                            <!-- <span><i class="fa fa-exclamation-circle yellow"></i>这里是默认长度</span> -->
                        </td>
                    </tr>
                    
                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
<script type="text/javascript">
var o = {
    a:function(obj){
        // console.log(obj)
        // alert(obj);
        // obj.success(999);
        if(obj.pid != ''){
            alert(123)
        }else{
            obj.pid = 0;
            o.b(obj);
            $('#'+obj.id[0]).live('change',function(){
                obj.pid = $(this).val();
                o.b(obj);
            });
        }
        // for (var i = 0; i <= json.length - 1; i++) {
        //     o.b(obj);
        //     // json[i].id
        //     str += '<option value="'+json[i].id+'">'+json[i].meun_name+'</option>';
        // }

    },
    b:function(obj){
        $.ajax({
            type:"get",
            url:obj.url+obj.pid,
            dataType:"json",
            success:function(json){
                o.c(obj,json);
                // console.log(json)
                // var str = '';
                // str += '<option value="0">==顶级菜单==</option>';
                // for (var i = 0; i <= json.length - 1; i++) {
                //     // json[i].id
                //     str += '<option value="'+json[i].id+'">'+json[i].meun_name+'</option>';
                // }
                // // $('#'+obj.id[0]).html(str);
                // for (var ii = 0; ii <= obj[id].length - 1; ii++) {
                //     $('#'+obj.id[ii]).html(str);
                // }
            }
        })
    },
    c:function(obj,json){

        var str = '';
        str += '<option value="0">==顶级菜单==</option>';
        for (var i = 0; i <= json.length - 1; i++) {
            // json[i].id
            str += '<option value="'+json[i].id+'">'+json[i].meun_name+'</option>';
        }
        $('#'+obj.id[0]).html(str);
        // for (var ii = 0; ii <= obj[id].length - 1; ii++) {
        //     $('#'+obj.id[ii]).html(str);
        // }

    }
};
o.a({
    url:'/backstage/meun/getMeun/',
    id:['one','tow','three'],
    pid:[],
    success:function(res){
        alert(res)
    }
    });
</script>
</body>
</html>